package sort;

import static sort.Common.printArray;

public class SelectSort {
    public static void sort(int[] nums) {
        int len = nums.length, min;
        for (int i = 0; i < len; ++i) {
            min = i;
            for (int j = i + 1; j < len; ++j)
                if (nums[j] < nums[min]) min = j;
            int tmp = nums[i];
            nums[i] = nums[min];
            nums[min] = tmp;
        }
    }



    public static void main(String[] args) {
        int[] nums = {1, 5, 2, 3, 0, -2, 6, 9, 8, 7};
        printArray(nums);
        sort(nums);
        printArray(nums);
    }
}
